package com.hpjpw.ido.controller;

import java.util.List;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.hpjpw.ido.domain.MessageReceive;
import com.hpjpw.ido.service.IMessageReceiveService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 消息阅读状态Controller
 * 
 * @author hpj
 * @date 2021-01-04
 */
@Api(value ="MessageReceiveController")
@RestController
@RequestMapping("/ido/message_receive")
public class MessageReceiveController extends BaseController
{
    @Autowired
    private IMessageReceiveService messageReceiveService;

    /**
     * 查询消息阅读状态列表
     */
    @PreAuthorize("@ss.hasPermi('ido:message_receive:list')")
    @GetMapping("/list")
    @ApiOperation("查询消息阅读状态列表")
    public TableDataInfo list(MessageReceive messageReceive)
    {
        startPage();
        List<MessageReceive> list = messageReceiveService.selectMessageReceiveList(messageReceive);
        return getDataTable(list);
    }

    /**
     * 导出消息阅读状态列表
     */
    @PreAuthorize("@ss.hasPermi('ido:message_receive:export')")
    @Log(title = "消息阅读状态", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    @ApiOperation("导出消息阅读状态列表")
    public AjaxResult export(MessageReceive messageReceive)
    {
        List<MessageReceive> list = messageReceiveService.selectMessageReceiveList(messageReceive);
        ExcelUtil<MessageReceive> util = new ExcelUtil<MessageReceive>(MessageReceive.class);
        return util.exportExcel(list, "message_receive");
    }

    /**
     * 获取消息阅读状态详细信息
     */
    @PreAuthorize("@ss.hasPermi('ido:message_receive:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取消息阅读状态详细信息")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(messageReceiveService.selectMessageReceiveById(id));
    }

    /**
     * 新增消息阅读状态
     */
    @PreAuthorize("@ss.hasPermi('ido:message_receive:add')")
    @Log(title = "消息阅读状态", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增消息阅读状态")
    public AjaxResult add(@RequestBody MessageReceive messageReceive)
    {
        return toAjax(messageReceiveService.insertMessageReceive(messageReceive));
    }

    /**
     * 修改消息阅读状态
     */
    @PreAuthorize("@ss.hasPermi('ido:message_receive:edit')")
    @Log(title = "消息阅读状态", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改消息阅读状态")
    public AjaxResult edit(@RequestBody MessageReceive messageReceive)
    {
        return toAjax(messageReceiveService.updateMessageReceive(messageReceive));
    }

    /**
     * 删除消息阅读状态
     */
    @PreAuthorize("@ss.hasPermi('ido:message_receive:remove')")
    @Log(title = "消息阅读状态", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation("删除消息阅读状态")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(messageReceiveService.deleteMessageReceiveByIds(ids));
    }
}
